﻿using Zhaoxi.ReadingPlatform.DataAccess;
using Zhaoxi.ReadingPlatform.Models;

internal class Program
{
    private static void Main(string[] args)
    {
        using (ReadingDbContext context = new ReadingDbContext())
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            context.BookEntities.Add(new BookEntity
            {
                Author = "李白",
                BannerUrl = "url",
                BookCategory = 1,
                BookCode = "GSC",
                Description = "古诗词",
                IsCharge = true,
                Name = "李白诗集",
                Press = "人教版"
            });

            context.SaveChanges();

            var book = context.BookEntities.OrderByDescending(x => x.Id).FirstOrDefault();

            book.Name += "2023";
            context.SaveChanges();

            context.BookEntities.Remove(book);
            context.SaveChanges();
        }
    }
}